#include "HufArc.h"

FILE * arc_file (fileHead * fileHd,FILE * fileToRead)
{
	char * tmpName = NULL;
	FILE* fileToRead_new = NULL;
	__HufTree * HufTree = NULL;
	char x[]="XXXXXX";
	HufTree = mkH_TInit (fileToRead);

	if (strlen(fileHd->fileName))
		tmpName = (char*) realloc (fileHd->fileName,strlen(fileHd->fileName) + 6);
	
	if (!tmpName)
		cl_exit (ARC_FILE,MEMORY_ERR);
	
	strcat (tmpName,x);
	
	tmpName = mktemp(tmpName);
	
	envInf.tmpFileName = tmpName;
	
	fileToRead_new = fopen (tmpName,"wb+");
	
	envInf.tmpFile_1 = fileToRead_new;
	
	if (!fileToRead_new)
		cl_exit (ARC_FILE,OPEN_FILE_ERR,envInf);
	
	fileToRead_new = compres (fileToRead_new,fileToRead,HufTree);
}